package com.iot.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageInfo;
import com.iot.common.constant.HttpStatus;
import com.iot.framework.rabbitmq.service.DeviceParamService;
import com.iot.framework.rabbitmq.service.DevicePowerService;
import com.iot.framework.rabbitmq.service.DeviceYieldService;
import com.iot.system.core.CoreDeviceYieldsService;
import com.iot.system.domain.vo.DeviceYieldsVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.iot.common.annotation.Log;
import com.iot.common.core.controller.BaseController;
import com.iot.common.core.domain.AjaxResult;
import com.iot.common.enums.BusinessType;
import com.iot.system.domain.DeviceYields;
import com.iot.system.service.IDeviceYieldsService;
import com.iot.common.utils.poi.ExcelUtil;
import com.iot.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author iot
 * @date 2024-11-18
 */
@RestController
@RequestMapping("/system/yields")
public class DeviceYieldsController extends BaseController
{
    @Autowired
    private CoreDeviceYieldsService coreDeviceYieldsService;
    @Autowired
    private IDeviceYieldsService deviceYieldsService;
    @Autowired
    private DeviceYieldService deviceYieldService;
    @Autowired
    private DeviceParamService deviceParamService;
    @Autowired
    private DevicePowerService devicePowerService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('results:yields:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeviceYields deviceYields)
    {
        //startPage();
        PageInfo<DeviceYieldsVo> list = coreDeviceYieldsService.selectDeviceYieldsList(deviceYields);
        TableDataInfo dataTable = getDataTable(list.getList());
        dataTable.setTotal(list.getTotal());
        dataTable.setCode(HttpStatus.SUCCESS);
        dataTable.setMsg("查询成功");
        dataTable.setRows(list.getList());
        return dataTable;
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('results:yields:export')")
    @Log(title = "导出", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceYields deviceYields)
    {
        PageInfo<DeviceYieldsVo> pageInfo = coreDeviceYieldsService.selectDeviceYieldsList(deviceYields);
        List<DeviceYieldsVo> list = pageInfo.getList();
        ExcelUtil<DeviceYieldsVo> util = new ExcelUtil<DeviceYieldsVo>(DeviceYieldsVo.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('results:yields:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(coreDeviceYieldsService.selectDeviceYieldsById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('results:yields:add')")
    @Log(title = "新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceYields deviceYields)
    {
        return toAjax(coreDeviceYieldsService.insertDeviceYields(deviceYields));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('results:yields:edit')")
    @Log(title = "修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceYields deviceYields)
    {
        return toAjax(coreDeviceYieldsService.updateDeviceYields(deviceYields));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('results:yields:remove')")
    @Log(title = "删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(coreDeviceYieldsService.deleteDeviceYieldsByIds(ids));
    }

    @PostMapping("/deviceYield")
    public AjaxResult deviceYield(@RequestBody String ids)
    {
        deviceYieldService.deviceYield(ids);
        //deviceParamService.deviceParam(ids);
        //devicePowerService.devicePower(ids);
        return toAjax(11);
    }


}
